// SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
// SPDX-License-Identifier: Mulan PSL v2
package com.geniusai.aip.auth.service;

import com.geniusai.aip.auth.domain.LoginEntity;
import com.geniusai.aip.auth.domain.ResponseTokenDTO;
import org.springframework.validation.annotation.Validated;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author hml14563
 * @date 2021/3/20
 */
@Validated
public interface LoginService {

    /**
     * 登陆请求
     * 
     * @param request     登陆请求
     * @param response    返回的response
     * @param loginEntity 登陆实体
     * @return token和是否是第一个登录的实体
     */
    ResponseTokenDTO login(HttpServletRequest request, LoginEntity loginEntity, HttpServletResponse response);

    /**
     * 退出功能
     * 
     * @param request http请求
     * @param session session 会话
     */
    void logout(HttpServletRequest request, HttpSession session);

    /**
     * 前端获取token
     * 
     * @param request  登陆请求
     * @param username 请求的用户名
     * @return token
     */
    String getToken(HttpServletRequest request, String username);

    /**
     * 获取本次请求是否允许
     * 
     * @param request  请求
     * @param response 请求
     * @return 返回实体信息
     */
    void getPermission(HttpServletRequest request, HttpServletResponse response);
}
